const path = require('path')
const fs = require('fs')
// ../会抵消前面的路径
let filePath = path.join('/a','/b/c','../','./d','e') 
let filePath2 = path.join('/a','/b/c','../../','./d','e') 
console.log(filePath) //\a\b\d\e
console.log(filePath2) // \a\d\e
console.log('---------');
console.log(__dirname);

fs.readFile(path.join(__dirname,'/file/成绩.txt'),'utf-8',(err,data) =>{
  if (err) {
    return console.log('读取文件失败',err.message);
  }
  console.log('读取文件成功',data);
})

// path.basename()获取文件名

const filePath3 = '/01-fs模块/03.考试成绩处理.js'

const fullName = path.basename(filePath3,'.js')
console.log(fullName,'fullName')

// 获取路径中的文件扩展名
console.log(path.extname(filePath3),'文件的扩展名');